The case transformation options for arguments don't work properly with special characters. strtoupper/strtolower/ucfirst/ucwords only transform alphabetic characters that belong the the system locale (though I can't actually get that to work on my Ubuntu server using sv_SE.utf-8 and taxonomy terms containing Swedish characters). Since it's likely that a multi-language site needs to transform characters that span across multiple locales I think it would be better to use the mb_* family of functions instead.
The patch also removes a duplicate occurence of case 'upper':
function case_transform($string, $option) {
switch ($this->options[$option]) {
default:
return $string;
case 'upper':
return mb_strtoupper($string);
case 'lower':
return mb_strtolower($string);
case 'ucfirst':
return mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1);
case 'ucwords':
return mb_convert_case($string, MB_CASE_TITLE);
}
}
Comments
Comment #1
merlinofchaos commentedMinor note: I prefer patches generated from the base 'views' directory to make it easy to apply.
Committed.
Comment #3
mr.baileysThis fix causes problems on installations where the PHP mbstring extension is not active, and the mb_* calls are not defined:
Drupal has a number of unicode functions that degrade gracefully if the mbstring extension is not present, so I'd suggest replacing the mb_* calls with their drupal_* counterparts. There is no matching function for mb_convert_case, so I've added a check to determine which function to run:
Comment #4
hawk259 commentedYes, this broke on my system. Thanks for the new patch!
Comment #5
dragonwize commentedbump
Comment #6
merlinofchaos commentedThanks! Committed.